#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
vector<int> v;
vector<vector<pair<int, int>>> w;
vector<bool> f;
vector<int>dp;
int ans=INT_MAX;
void dfs(int p,int tmp)
{
    // if(tmp&&dp[p]>tmp)dp[p]=tmp;
    // else return ;
    if(dp[p]&&tmp&&dp[p]<=tmp)return ;
    dp[p]=tmp;
    if(f[p])return ;
    f[p]=1;
    if(p==n)
    {
        ans=min(ans,tmp-v[1]);
    }
    for(auto x:w[p])
    {
        dfs(x.first,tmp+x.second+v[p]);
    }
    f[p]=0;
}
void solve()
{  
    cin>>n>>m;
    v=vector<int> (n+1);
    w=vector<vector<pair<int, int>>> (n+1);
    dp=vector<int>(n+1);
    f=vector<bool> (n+1);
    for(int i=1;i<=n;i++)cin>>v[i];
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        w[x].push_back({y,z});
        w[y].push_back({x,z});
    }
    dfs(1,0);
    cout<<ans<<endl;
}
signed main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)
    {
       solve();
    }
    return 0;
}